/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ventas_sie_apartados_catalogo.java
 *
 * Created on 21/06/2011, 11:20:53 AM
 */

package sie_invdis;


import java.sql.*;
import javax.swing.*;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTable.*;
import java.awt.*;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.text.*;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Michelle
 */
public class ventas_sie_apartados_catalogo extends javax.swing.JFrame {

    DefaultTableCellRenderer alinearCentro, alinearderecha, alinearIzquierda;
    private javax.swing.table.DefaultTableModel jtable_modelo;
    private javax.swing.table.DefaultTableModel jtable_modelo_credito;
    private JTable jtable_tiendas;

    private int buscamp=1,tienda=0,indexactual=0,yacarguecredito=0,yacargueapa=1,centrar=0;


    private int control_enter=0,controlcombo=0;
    private SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
    private SimpleDateFormat formateadoresta = new SimpleDateFormat("yyyy-MM-dd");
    //se crea intancia de la clase conexion
       bd_conexion x = new bd_conexion() ;
       //se creaa la variable resultset
       ResultSet rs = null;
       //llamo almetodo para establecer la conexion

   
    /** Creates new form ventas_sie_apartados_catalogo */
    public ventas_sie_apartados_catalogo() {
        this.iniciar_modelo_de_tabla();
        this.iniciar_modelo_credito();
        initComponents();

        this.setLocation(25,25);
        if (variables_global.getnivelusu()==3)
            {
              tienda=variables_global.getidtiendami();
            }
        if(JOptionPane.showConfirmDialog(null, "Desea Cargar Datos?")==0)
            {
                this.carga_datos(1, tienda,"");
            }
        this.jcbx_tiendas.addItem(variables_global.getidtiendami()+":"+variables_global.getidtiendamidescribe());

    jt_apartadoscatalogo.getColumnModel().getColumn(0).setPreferredWidth(30);//Folio
    jt_apartadoscatalogo.getColumnModel().getColumn(1).setPreferredWidth(50);//status
    jt_apartadoscatalogo.getColumnModel().getColumn(2).setPreferredWidth(180);//doc ant.
    jt_apartadoscatalogo.getColumnModel().getColumn(3).setPreferredWidth(80);//fecha
    jt_apartadoscatalogo.getColumnModel().getColumn(4).setPreferredWidth(25);//fecha llega tienda
    jt_apartadoscatalogo.getColumnModel().getColumn(5).setPreferredWidth(25);//f.recepcion
    jt_apartadoscatalogo.getColumnModel().getColumn(6).setPreferredWidth(50);//Dias Trans.
    jt_apartadoscatalogo.getColumnModel().getColumn(7).setPreferredWidth(40);//guia
    jt_apartadoscatalogo.getColumnModel().getColumn(8).setPreferredWidth(40);//Cliente
    jt_apartadoscatalogo.getColumnModel().getColumn(9).setPreferredWidth(40);//piezas
    jt_apartadoscatalogo.getColumnModel().getColumn(10).setPreferredWidth(50);//Observaciones
    jt_apartadoscatalogo.getColumnModel().getColumn(10).setPreferredWidth(60);//Observaciones

    jt_apartadoscatalogo.getTableHeader().setBackground(Color.yellow);


        jtb_credito.getColumnModel().getColumn(0).setPreferredWidth(60);//tipo
        jtb_credito.getColumnModel().getColumn(1).setPreferredWidth(50);//Tipo Pago
        jtb_credito.getColumnModel().getColumn(2).setPreferredWidth(220);//Fecha
        jtb_credito.getColumnModel().getColumn(3).setPreferredWidth(80);//Hora
        jtb_credito.getColumnModel().getColumn(4).setPreferredWidth(15);//Folio Impreso
        jtb_credito.getColumnModel().getColumn(5).setPreferredWidth(15);//Remision
        jtb_credito.getColumnModel().getColumn(6).setPreferredWidth(60);//Pèdod
        jtb_credito.getColumnModel().getColumn(7).setPreferredWidth(35);//Total Venta
        jtb_credito.getColumnModel().getColumn(8).setPreferredWidth(35);//Pago moneda
        jtb_credito.getColumnModel().getColumn(9).setPreferredWidth(35);//Factor
        jtb_credito.getColumnModel().getColumn(10).setPreferredWidth(60);//Pago en Pesos
        jtb_credito.getColumnModel().getColumn(11).setPreferredWidth(20);//Cakerp

     this.buttonGroup1.setSelected(jrbtn_obserdocto.getModel(),true);
    this.loadcombo();
    controlcombo=1;
    this.jtf_busqueda.requestFocus();
    yacargueapa=0;
    centrar=1;

    this.jLabel4.setText("Texto Buscado:Apartados Vencidos");

    }

 private void loadcombo(){
          jtable_tiendas=variables_global.gettabla_tiendas();
         int numerotiendas=this.jtable_tiendas.getRowCount();
         this.jcbx_tiendas.addItem("0:Elija tienda");
          for(int ii=0;ii<numerotiendas;ii++)
                        {
                            this.jcbx_tiendas.addItem(jtable_tiendas.getValueAt(ii, 1)+":"+jtable_tiendas.getValueAt(ii, 0));
                        }
    }

private void iniciar_modelo_de_tabla()
    {
        jtable_modelo=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo.addColumn("<html><b>Tienda</b></html>");
        jtable_modelo.addColumn("<html><b>Status</b></html>");
        jtable_modelo.addColumn("<html><b>Cliente</b></html>");
        jtable_modelo.addColumn("<html><b>Telefono/Email</b></html>");
        jtable_modelo.addColumn("<html><b>Folio</b></html>");
        jtable_modelo.addColumn("<html><b>Remision</b></html>");
        jtable_modelo.addColumn("<html><b>Fecha</b></html>");
        jtable_modelo.addColumn("<html><b>Importe A.</b></html>");
        jtable_modelo.addColumn("<html><b>Abonos</b></html>");
        jtable_modelo.addColumn("<html><b>saldo</b></html>");
        jtable_modelo.addColumn("<html><b>Vencimiento</b></html>");
        jtable_modelo.addColumn("<html><b>Dias Trans</b></html>");
}

private void iniciar_modelo_credito()
    {
        jtable_modelo_credito=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_credito.addColumn("<html><b>Tienda</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Status</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Cliente</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Telefono/Email</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Folio</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Remision</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Fecha</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Importe A.</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Abonos</b></html>");
        jtable_modelo_credito.addColumn("<html><b>saldo</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Vencimiento</b></html>");
        jtable_modelo_credito.addColumn("<html><b>Dias Trans</b></html>");
}


private void carga_datos_creditocatalogo(int opcion,String tienda,String busca1,String busca2)
    {
       String fechacat = "",fechallegatienda="",fechaentrega="",abrehtml="",cierrahtml="",stienda[]=null;
       DecimalFormat miformat = new DecimalFormat("###,###,###,###");
       while(jtable_modelo_credito.getRowCount()>0)jtable_modelo_credito.removeRow(0);
       Object[] fnewRow = new Object[12];
       String texto="";

       texto="select * from x1venta_credito_catalogo("+opcion+",'"+tienda+"','"+busca1+"','"+busca2+"','') as (idcrecxc integer,idcredito integer,idnivel_1 integer,totalcredito real,idcatdescuento integer,idcliente integer,idstatus integer,totalcreditonodescuento real,descuento real,fechapago date,fecha date, hora time,idempleado integer,nombre text,celular text,email text,direccion text,nombreestatus text,dias integer);";
       System.out.println(texto);
        try
         {
               rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
               while (rs.next())
                    {
                        switch (rs.getInt("idstatus"))
                        {
                            case 1:
                                abrehtml="<html><b><font color=#0000FF>";
                                cierrahtml="<font></b></html>";
                            break;
                            case 5:
                                 abrehtml="<html>";
                                 cierrahtml="</html>";
                            break;
                            default:
                                 abrehtml="<html><b><font color=#FF6633>";
                                 cierrahtml="<font></b></html>";
                            break;
                        }
                    if(rs.getString("idcrecxc") != null)
                            {
                                fnewRow[5]=abrehtml+rs.getString("idcrecxc")+cierrahtml;
                                //fnewRow[11]=abrehtml+rs.getString("horapago").substring(0, 5)+cierrahtml;
                            }
                    else
                            {
                                fnewRow[5]="";
                            }
                     stienda=rs.getString("nombre").split(":");
                     fnewRow[0]=abrehtml+stienda[2]+":"+stienda[0]+cierrahtml;
                     fnewRow[1]=abrehtml+rs.getString("idstatus")+":"+rs.getString("nombreestatus").toUpperCase()+cierrahtml;
                     fnewRow[2]=abrehtml+stienda[1]+"<br>"+rs.getString("direccion")+cierrahtml;
                     //fnewRow[3]=abrehtml+rs.getString("celular")+"<br>"+rs.getString("email")+cierrahtml;
                     fnewRow[3]="";
                     fnewRow[4]=abrehtml+rs.getString("idcredito")+cierrahtml;

                     fnewRow[6]=abrehtml+this.fechaeuropea(rs.getString("fecha"))+" "+rs.getString("hora").substring(0,5)+ "<br>"+this.DiaSemana(this.fechaeuropea(rs.getString("fecha")))+cierrahtml;
                     fnewRow[7]=abrehtml+miformat.format(rs.getFloat("totalcredito"))+cierrahtml;
                     fnewRow[8]=abrehtml+""+cierrahtml;
                     fnewRow[9]=abrehtml+""+cierrahtml;
                     fnewRow[10]=abrehtml+this.fechaeuropea(rs.getString("fechapago"))+ "<br>"+this.DiaSemana(this.fechaeuropea(rs.getString("fechapago")))+cierrahtml;
                     fnewRow[11]=abrehtml+rs.getString("dias")+cierrahtml;
                     jtable_modelo_credito.addRow(fnewRow);
                    }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
     }


private void diodblclickcre(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
         int fila = jtb_credito.getSelectedRow();
         String idcadena[]=this.jtb_credito.getValueAt(fila, 0).toString().split(":");
         String idcadenaemp=this.jtb_credito.getValueAt(fila, 4).toString().replace("<b>", "").replace("</b>", "").replace("<font color=#0000FF>", "").replace("<font color=#FF6633>", "").replace("<html>", "").replace("</html>", "").replace("<font>", "");
         System.out.println(idcadena[0]+" loqueenvio"+idcadenaemp);
         //JFrame mainFrame = Sie_invdisApp.getApplication().getMainFrame();
         ventas_sie_apartados_detalle fsrhe=new ventas_sie_apartados_detalle(2,idcadena[0].replace("<b>", "").replace("</b>", "").replace("<font color=#0000FF>", "").replace("<font color=#FF6633>", "").replace("<html>", "").replace("</html>", "").replace("<font>", ""),idcadenaemp);
         fsrhe.pack();
         fsrhe.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel2 = new javax.swing.JPanel();
        jcbx_tiendas = new javax.swing.JComboBox();
        jtf_busqueda = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jbtn_busqueda = new javax.swing.JButton();
        jrbtn_folio = new javax.swing.JRadioButton();
        jrbtn_doctoanterio = new javax.swing.JRadioButton();
        jrbtn_obserdocto = new javax.swing.JRadioButton();
        jrbtn_general = new javax.swing.JRadioButton();
        jRadioButton1 = new javax.swing.JRadioButton();
        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jbtn_estadistica = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jt_apartadoscatalogo = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }
        };
        jLabel4 = new javax.swing.JLabel();
        jlbl_textobuscado = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jlbl_cantidadregistros = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane10 = new javax.swing.JScrollPane();
        jtb_credito = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }}
            ;
            jMenuBar1 = new javax.swing.JMenuBar();
            jMenu1 = new javax.swing.JMenu();
            jmni_salir = new javax.swing.JMenuItem();
            jMenu2 = new javax.swing.JMenu();
            jmni_escape = new javax.swing.JMenuItem();
            jmni_actualizar = new javax.swing.JMenuItem();
            jMenu3 = new javax.swing.JMenu();

            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(ventas_sie_apartados_catalogo.class);
            setTitle(resourceMap.getString("Form.title")); // NOI18N
            setName("Form"); // NOI18N

            jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel2.border.title"))); // NOI18N
            jPanel2.setName("jPanel2"); // NOI18N

            jcbx_tiendas.setToolTipText(resourceMap.getString("jcbx_tiendas.toolTipText")); // NOI18N
            jcbx_tiendas.setName("jcbx_tiendas"); // NOI18N
            jcbx_tiendas.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jcbx_tiendasActionPerformed(evt);
                }
            });

            jtf_busqueda.setToolTipText(resourceMap.getString("jtf_busqueda.toolTipText")); // NOI18N
            jtf_busqueda.setName("jtf_busqueda"); // NOI18N
            jtf_busqueda.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jtf_busquedaActionPerformed(evt);
                }
            });

            jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
            jLabel1.setName("jLabel1"); // NOI18N

            jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
            jLabel2.setName("jLabel2"); // NOI18N

            jbtn_busqueda.setIcon(resourceMap.getIcon("jbtn_busqueda.icon")); // NOI18N
            jbtn_busqueda.setText(resourceMap.getString("jbtn_busqueda.text")); // NOI18N
            jbtn_busqueda.setToolTipText(resourceMap.getString("jbtn_busqueda.toolTipText")); // NOI18N
            jbtn_busqueda.setName("jbtn_busqueda"); // NOI18N
            jbtn_busqueda.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jbtn_busquedaActionPerformed(evt);
                }
            });

            buttonGroup1.add(jrbtn_folio);
            jrbtn_folio.setText(resourceMap.getString("jrbtn_folio.text")); // NOI18N
            jrbtn_folio.setToolTipText(resourceMap.getString("jrbtn_folio.toolTipText")); // NOI18N
            jrbtn_folio.setActionCommand(resourceMap.getString("jrbtn_folio.actionCommand")); // NOI18N
            jrbtn_folio.setName("jrbtn_folio"); // NOI18N
            jrbtn_folio.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jrbtn_folioActionPerformed(evt);
                }
            });

            buttonGroup1.add(jrbtn_doctoanterio);
            jrbtn_doctoanterio.setText(resourceMap.getString("jrbtn_doctoanterio.text")); // NOI18N
            jrbtn_doctoanterio.setToolTipText(resourceMap.getString("jrbtn_doctoanterio.toolTipText")); // NOI18N
            jrbtn_doctoanterio.setActionCommand(resourceMap.getString("jrbtn_doctoanterio.actionCommand")); // NOI18N
            jrbtn_doctoanterio.setName("jrbtn_doctoanterio"); // NOI18N
            jrbtn_doctoanterio.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jrbtn_doctoanterioActionPerformed(evt);
                }
            });

            buttonGroup1.add(jrbtn_obserdocto);
            jrbtn_obserdocto.setText(resourceMap.getString("jrbtn_obserdocto.text")); // NOI18N
            jrbtn_obserdocto.setToolTipText(resourceMap.getString("jrbtn_obserdocto.toolTipText")); // NOI18N
            jrbtn_obserdocto.setActionCommand(resourceMap.getString("jrbtn_obserdocto.actionCommand")); // NOI18N
            jrbtn_obserdocto.setName("jrbtn_obserdocto"); // NOI18N
            jrbtn_obserdocto.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jrbtn_obserdoctoActionPerformed(evt);
                }
            });

            buttonGroup1.add(jrbtn_general);
            jrbtn_general.setText(resourceMap.getString("jrbtn_general.text")); // NOI18N
            jrbtn_general.setActionCommand(resourceMap.getString("jrbtn_general.actionCommand")); // NOI18N
            jrbtn_general.setName("jrbtn_general"); // NOI18N
            jrbtn_general.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jrbtn_generalActionPerformed(evt);
                }
            });

            buttonGroup1.add(jRadioButton1);
            jRadioButton1.setText(resourceMap.getString("jRadioButton1.text")); // NOI18N
            jRadioButton1.setToolTipText(resourceMap.getString("jRadioButton1.toolTipText")); // NOI18N
            jRadioButton1.setActionCommand(resourceMap.getString("jRadioButton1.actionCommand")); // NOI18N
            jRadioButton1.setName("jRadioButton1"); // NOI18N
            jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jRadioButton1ActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
            jPanel2.setLayout(jPanel2Layout);
            jPanel2Layout.setHorizontalGroup(
                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGap(231, 231, 231)
                    .addComponent(jLabel2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jtf_busqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(jbtn_busqueda)
                    .addGap(15, 15, 15)
                    .addComponent(jLabel1)
                    .addGap(18, 18, 18)
                    .addComponent(jcbx_tiendas, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(195, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                    .addGap(249, 249, 249)
                    .addComponent(jrbtn_general)
                    .addGap(18, 18, 18)
                    .addComponent(jrbtn_folio, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(jrbtn_doctoanterio)
                    .addGap(18, 18, 18)
                    .addComponent(jrbtn_obserdocto)
                    .addGap(18, 18, 18)
                    .addComponent(jRadioButton1)
                    .addGap(370, 370, 370))
            );
            jPanel2Layout.setVerticalGroup(
                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jtf_busqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2)
                        .addComponent(jbtn_busqueda)
                        .addComponent(jcbx_tiendas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jrbtn_obserdocto, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jrbtn_doctoanterio, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jrbtn_folio, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jrbtn_general)
                        .addComponent(jRadioButton1))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );

            jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
            jPanel3.setName("jPanel3"); // NOI18N

            jButton1.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
            jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
            jButton1.setName("jButton1"); // NOI18N
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });

            jbtn_estadistica.setIcon(resourceMap.getIcon("jbtn_estadistica.icon")); // NOI18N
            jbtn_estadistica.setText(resourceMap.getString("jbtn_estadistica.text")); // NOI18N
            jbtn_estadistica.setToolTipText(resourceMap.getString("jbtn_estadistica.toolTipText")); // NOI18N
            jbtn_estadistica.setName("jbtn_estadistica"); // NOI18N
            jbtn_estadistica.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jbtn_estadisticaActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
            jPanel3.setLayout(jPanel3Layout);
            jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addComponent(jbtn_estadistica)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 810, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addContainerGap())
            );
            jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jbtn_estadistica))
            );

            jTabbedPane1.setName("jTabbedPane1"); // NOI18N
            jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
                public void stateChanged(javax.swing.event.ChangeEvent evt) {
                    jTabbedPane1StateChanged(evt);
                }
            });

            jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
            jPanel1.setName("jPanel1"); // NOI18N

            jScrollPane2.setName("jScrollPane2"); // NOI18N

            jt_apartadoscatalogo.setModel(this.jtable_modelo);
            jt_apartadoscatalogo.setName("jt_apartadoscatalogo"); // NOI18N
            jt_apartadoscatalogo.getTableHeader().setReorderingAllowed(false);
            jt_apartadoscatalogo.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jt_apartadoscatalogoMouseClicked(evt);
                    if(evt.getClickCount() >= 2)
                    {
                        diodblclick(evt);
                        //System.out.println(" double click" );

                    }
                }
            });
            jScrollPane2.setViewportView(jt_apartadoscatalogo);

            jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
            jLabel4.setName("jLabel4"); // NOI18N

            jlbl_textobuscado.setFont(resourceMap.getFont("jlbl_textobuscado.font")); // NOI18N
            jlbl_textobuscado.setText(resourceMap.getString("jlbl_textobuscado.text")); // NOI18N
            jlbl_textobuscado.setName("jlbl_textobuscado"); // NOI18N

            jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
            jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
            jLabel3.setName("jLabel3"); // NOI18N

            jlbl_cantidadregistros.setFont(resourceMap.getFont("jlbl_cantidadregistros.font")); // NOI18N
            jlbl_cantidadregistros.setText(resourceMap.getString("jlbl_cantidadregistros.text")); // NOI18N
            jlbl_cantidadregistros.setName("jlbl_cantidadregistros"); // NOI18N

            jLabel5.setFont(resourceMap.getFont("jLabel5.font")); // NOI18N
            jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
            jLabel5.setName("jLabel5"); // NOI18N

            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addComponent(jLabel4)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jlbl_textobuscado, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel3)
                    .addGap(18, 18, 18)
                    .addComponent(jlbl_cantidadregistros, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel5)
                    .addContainerGap(654, Short.MAX_VALUE))
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 1007, Short.MAX_VALUE)
            );
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel5)
                        .addComponent(jlbl_cantidadregistros)
                        .addComponent(jLabel3)
                        .addComponent(jLabel4)
                        .addComponent(jlbl_textobuscado))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 442, Short.MAX_VALUE)
                    .addContainerGap())
            );

            jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

            jPanel4.setName("jPanel4"); // NOI18N

            jScrollPane10.setName("jScrollPane10"); // NOI18N

            jtb_credito.setModel(this.jtable_modelo_credito);
            jtb_credito.setName("jtb_credito"); // NOI18N
            jtb_credito.setRowHeight(26);
            jtb_credito.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jtb_creditoMouseClicked(evt);
                    if(evt.getClickCount() >= 2)
                    {
                        diodblclickcre(evt);
                        //System.out.println(" double click" );

                    }
                }
            });
            jScrollPane10.setViewportView(jtb_credito);

            javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
            jPanel4.setLayout(jPanel4Layout);
            jPanel4Layout.setHorizontalGroup(
                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 1009, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(jScrollPane10, javax.swing.GroupLayout.DEFAULT_SIZE, 999, Short.MAX_VALUE)
                        .addGap(5, 5, 5)))
            );
            jPanel4Layout.setVerticalGroup(
                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 477, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(35, 35, 35)
                        .addComponent(jScrollPane10, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
                        .addContainerGap()))
            );

            jTabbedPane1.addTab(resourceMap.getString("jPanel4.TabConstraints.tabTitle"), jPanel4); // NOI18N

            jMenuBar1.setName("jMenuBar1"); // NOI18N

            jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
            jMenu1.setName("jMenu1"); // NOI18N

            jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
            jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
            jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
            jmni_salir.setName("jmni_salir"); // NOI18N
            jmni_salir.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jmni_salirActionPerformed(evt);
                }
            });
            jMenu1.add(jmni_salir);

            jMenuBar1.add(jMenu1);

            jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
            jMenu2.setName("jMenu2"); // NOI18N

            jmni_escape.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
            jmni_escape.setText(resourceMap.getString("jmni_escape.text")); // NOI18N
            jmni_escape.setName("jmni_escape"); // NOI18N
            jmni_escape.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jmni_escapeActionPerformed(evt);
                }
            });
            jMenu2.add(jmni_escape);

            jmni_actualizar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0));
            jmni_actualizar.setIcon(resourceMap.getIcon("jmni_actualizar.icon")); // NOI18N
            jmni_actualizar.setText(resourceMap.getString("jmni_actualizar.text")); // NOI18N
            jmni_actualizar.setName("jmni_actualizar"); // NOI18N
            jmni_actualizar.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jmni_actualizarActionPerformed(evt);
                }
            });
            jMenu2.add(jmni_actualizar);

            jMenuBar1.add(jMenu2);

            jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
            jMenu3.setName("jMenu3"); // NOI18N
            jMenuBar1.add(jMenu3);

            setJMenuBar(jMenuBar1);

            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1014, Short.MAX_VALUE)
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 505, Short.MAX_VALUE))
            );

            pack();
        }// </editor-fold>//GEN-END:initComponents

     private String  fechaeuropea(String fecha) {

         //resibe cadena de fecha en formato americano yyyy-MM-dd
        java.util.Date fechaestaeuropa=null;
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("dd-MM-yyyy");
       String cadenafecha="";
        try
         {
          fechaestaeuropa = formateadoresta.parse(fecha);
         }
        catch (ParseException e)
          {
             //Error, la cadena de texto no se puede convertir en fecha.
          }
       cadenafecha= formateadorestaeuropa.format(fechaestaeuropa);
       return cadenafecha;

    }
     private String DiaSemana(String fe) {
         String dia = "";
       java.util.Date fecha=null;
         try
            {
             fecha = formateador.parse(fe);

           }
        catch (ParseException e)
            {
            //Error, la cadena de texto no se puede convertir en fecha.
            }
        Calendar cal= Calendar.getInstance();
        cal.setTime(fecha);
        //ojo para establecer o recetear cada parte de la fecha por separado
        //cal.set(Calendar.YEAR, fecha.getYear());
        //cal.set(Calendar.MONTH, fecha.getMonth());
        //cal.set(Calendar.DAY_OF_MONTH, fecha.getDay());
        int diaInt = cal.get(Calendar.DAY_OF_WEEK);
        switch (diaInt) {
            case 1:
                dia = "Domingo";
                break;
            case 2:
                dia = "Lunes";
                break;
            case 3:
                dia = "Martes";
                break;
            case 4:
                dia = "Miercoles";
                break;
            case 5:
                dia = "Jueves";
                break;
            case 6:
                dia = "Viernes";
                break;
            case 7:
                dia = "Sabado";
                break;

        }
        return dia;
    }

private  void ayuda()
            {
                JOptionPane.showMessageDialog(null," 1.-Catalogo de Recepciones de Mercancia, cada una de las Opciones se autodescribe brevemente\n 2.- Cada Boton tiene Una letra Resaltada el cual indica su metodo abreviado, uselo si desea mayor rapides ( ejemplo Alt+a obtendra ayuda automaticamente)\n 3.- Para ver Detalle de un documento de Doble clik sobre el registro sombreado o use las teclas arriba o abajo luego precione enter y aparecera otra pantalla. \n ", "Sistema Integral(Detalle Recepcion) : Ayuda",1);
            }

private void crearcomentario()
          {
                 String retorno="";

        String comentario=JOptionPane.showInputDialog("Ingresa Tu Sugerencia o Comentario:");
        if (comentario.length()>0)
        {
            rs = x.sieuno_executediversosv2("select * from x1distribucion_bitacorainserta('"+comentario+"', 'Catalogo Recepciones');",variables_global.getconexiongral());
            try
            {

               while (rs.next())
                    {
                         retorno=rs.getString(1);
                   }
             }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
            if (retorno.equals("1"))
              {
                JOptionPane.showMessageDialog(null,"Gracias Tu comentario ha sido guardado", "Sistema Integral Comentarios",1);

              }

      }
    }

    private void jcbx_tiendasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbx_tiendasActionPerformed
        // TODO add your handling code here:

        int fidtienda=0;

        if (controlcombo > 0 ) {
                if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus Datos?")==0)
                        {
                            String arreglo_idtie[]=null;
                            arreglo_idtie=this.jcbx_tiendas.getSelectedItem().toString().split(":");
                            fidtienda=Integer.valueOf(arreglo_idtie[0]);
                            this.carga_datos(0,fidtienda,"");
                        }
          }

        //this.jtfpruebados.setText(jtable_tiendas.getValueAt(indeceta, 0).toString());
}//GEN-LAST:event_jcbx_tiendasActionPerformed
private void carga_datos(int opcion,int idtienda,String busca)
 {
        String fechacat = "",fechallegatienda="",fechaentrega="";
        DecimalFormat miformat = new DecimalFormat("###,###,###,###");

        java.util.Date fechahoy=new Date();
        int diastrans=0;
        Object[] fnewRow = new Object[12];
       //invoco al metodo que trae el recordset de datos
       String arreglo_idtie[]=null;
       this.LimpiarJTable();


        try
         {
            rs = x.sieuno_executediversosv2("select * from x1venta_apartados_catalogo("+opcion+","+idtienda+",'"+busca+"') as (idapartado integer,idremapartado integer,idnivel_1 integer,totalapartado double precision,idcatdescuento integer,idcliente integer,idstatus integer,totalventanodescuento real,descuento real,fecha date, hora time without time zone,idempleado integer,saldo double precision,nombre text,celular text,fechavenci date,dias integer,email text,direccion text,nombreestatus text);",variables_global.getconexiongral());
            while (rs.next())
                {
                 arreglo_idtie=rs.getString ("nombre").toString().split(":");
                 fnewRow[0]=arreglo_idtie[2]+":"+arreglo_idtie[0];
                  if((rs.getInt("idstatus") == 0 ) || (rs.getInt("idstatus") == 9 ) || (rs.getInt("idstatus") == 18 ))
                    {
                        fnewRow[1]="<html><b><font color=#CC0000>"+rs.getString ("idstatus")+":"+rs.getString ("nombreestatus")+"<font></b></html>";
                    }
                  else
                    {
                        fnewRow[1]=""+rs.getString ("idstatus")+":"+rs.getString ("nombreestatus")+"";
                    }
                 fnewRow[2]="<html>"+arreglo_idtie[1]+"<br>"+rs.getString ("direccion")+"</html>";
                 fnewRow[3]="<html>"+rs.getString ("celular")+"<br>"+rs.getString ("email")+"</html>";
                 fnewRow[4]=rs.getString ("idapartado");
                 fnewRow[5]=rs.getString ("idremapartado");
                 if(rs.getString ("fecha") != null )
                    {
                        fnewRow[6]="<html>"+this.fechaeuropea(rs.getString ("fecha"))+"<br>"+DiaSemana(this.fechaeuropea(rs.getString ("fecha")))+"</html>";
                    }
                 fnewRow[7]=miformat.format(rs.getFloat("totalapartado"));
                 fnewRow[8]=miformat.format(rs.getFloat("totalapartado")-rs.getFloat("saldo"));
                 fnewRow[9]=miformat.format(rs.getFloat("saldo"));
                 if(rs.getString ("fechavenci") != null )
                     {
                         fnewRow[10]="<html>"+this.fechaeuropea(rs.getString ("fechavenci"))+":<br>"+DiaSemana(this.fechaeuropea(rs.getString ("fechavenci")))+"</html>";
                     }
                 if(rs.getFloat("saldo") != 0 )
                     {
                        fnewRow[11]=this.mensajetiempo(rs.getInt("dias"));
                     }
                 else
                     {
                        fnewRow[11]="Liquidado";
                     }
                 if((rs.getInt("idstatus") == 0 ) || (rs.getInt("idstatus") == 9 ) || (rs.getInt("idstatus") == 18 ))
                     {
                        fnewRow[11]="";
                     }
                 jtable_modelo.addRow(fnewRow);
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
        this.cambiartamanofilas();
        this.registrosobtenidos();
}
void registrosobtenidos()
 {
     //limpiar la tabla
    this.jlbl_cantidadregistros.setText(String.valueOf(this.jtable_modelo.getRowCount()));
    this.jlbl_textobuscado.setText(this.jtf_busqueda.getText().toUpperCase().trim());
 }

    private void jtf_busquedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_busquedaActionPerformed
        // TODO add your handling code here:
        this.jbtn_busquedaActionPerformed(evt);
}//GEN-LAST:event_jtf_busquedaActionPerformed

    private void jbtn_busquedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_busquedaActionPerformed
        // TODO add your handling code here:

        String arreglo_idtie[]=this.jcbx_tiendas.getSelectedItem().toString().split(":");
        int fidtienda=Integer.valueOf(arreglo_idtie[0]);

        if(JOptionPane.showConfirmDialog(null, "Estan correcto sus Datos?")==0)
            {
            yacargueapa=0;
            yacarguecredito=0;

             if(indexactual==0)
                {
                    yacargueapa=1;
                    this.carga_datos(buscamp,fidtienda,this.jtf_busqueda.getText().trim().toUpperCase());
                }
               if(indexactual==1)
                {
                    yacarguecredito=1;
                    this.carga_datos_creditocatalogo(0,"7","","");
                }
            this.centrar_datos();
            }
    }//GEN-LAST:event_jbtn_busquedaActionPerformed

    private void jrbtn_folioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbtn_folioActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
}//GEN-LAST:event_jrbtn_folioActionPerformed

    private void jrbtn_doctoanterioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbtn_doctoanterioActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
}//GEN-LAST:event_jrbtn_doctoanterioActionPerformed

    private void jrbtn_obserdoctoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbtn_obserdoctoActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
}//GEN-LAST:event_jrbtn_obserdoctoActionPerformed

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
      if(JOptionPane.showConfirmDialog(null, "Desea Salir?")==0) {
             this.dispose();
        }
    }//GEN-LAST:event_jmni_salirActionPerformed

    private void jrbtn_generalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbtn_generalActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
    }//GEN-LAST:event_jrbtn_generalActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        //x.cierraConexion();   // TODO add your handling code here:
        this.dispose();
}//GEN-LAST:event_jButton1ActionPerformed

    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
    }//GEN-LAST:event_jRadioButton1ActionPerformed

    private void jmni_escapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_escapeActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_escapeActionPerformed

    private void jbtn_estadisticaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_estadisticaActionPerformed
        // TODO add your handling code here:

        ventas_sie_apartados_estadisticas fvsae=new ventas_sie_apartados_estadisticas();
        fvsae.pack();
        fvsae.setVisible(true);

    }//GEN-LAST:event_jbtn_estadisticaActionPerformed

    private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
        // TODO add your handling code here:
                  indexactual=this.jTabbedPane1.getSelectedIndex();
               String arreglo_idtie[]=null;
               int fidtienda=0;
               if((indexactual==0)&&(yacargueapa==0))
                {
                arreglo_idtie=this.jcbx_tiendas.getSelectedItem().toString().split(":");
                fidtienda=Integer.valueOf(arreglo_idtie[0]);
                    yacargueapa=1;
                    this.carga_datos(buscamp,fidtienda,this.jtf_busqueda.getText().trim().toUpperCase());
                }
               if((indexactual==1)&&(yacarguecredito==0))
                {
                arreglo_idtie=this.jcbx_tiendas.getSelectedItem().toString().split(":");
                fidtienda=Integer.valueOf(arreglo_idtie[0]);
                    yacarguecredito=1;
                    this.carga_datos_creditocatalogo(0,"7","","");
                }
                 this.centrar_datos();
    }//GEN-LAST:event_jTabbedPane1StateChanged

    private void jmni_actualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_actualizarActionPerformed
        // TODO add your handling code here:
        String arreglo_idtie[]=this.jcbx_tiendas.getSelectedItem().toString().split(":");
        int fidtienda=Integer.valueOf(arreglo_idtie[0]);
        
            if(JOptionPane.showConfirmDialog(null, "Desea Actualizar Datos?")==0)
            {
            yacargueapa=0;
            yacarguecredito=0;

             if(indexactual==0)
                {
                    yacargueapa=1;
                    this.carga_datos(buscamp,fidtienda,this.jtf_busqueda.getText().trim().toUpperCase());
                }
               if(indexactual==1)
                {
                    yacarguecredito=1;
                    this.carga_datos_creditocatalogo(0,"7","","");
                }
            this.centrar_datos();
            }
    }//GEN-LAST:event_jmni_actualizarActionPerformed
  private void diodblclick(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
         int fila = jt_apartadoscatalogo.getSelectedRow();
         String idcadena[]=this.jt_apartadoscatalogo.getValueAt(fila, 0).toString().split(":");
         String idcadenaemp=this.jt_apartadoscatalogo.getValueAt(fila, 4).toString();
         System.out.println(idcadena[0]+" loqueenvio"+idcadenaemp);
         //JFrame mainFrame = Sie_invdisApp.getApplication().getMainFrame();
         ventas_sie_apartados_detalle fsrhe=new ventas_sie_apartados_detalle(idcadena[0],idcadenaemp);
         fsrhe.pack();
         fsrhe.setVisible(true);
    }


public void centrar_datos()
    {
        alinearderecha = new DefaultTableCellRenderer();
        alinearderecha.setHorizontalAlignment(SwingConstants.RIGHT);

        if(centrar==1)
            {

                  jtb_credito.getColumnModel().getColumn(7).setCellRenderer(alinearderecha);
                  jtb_credito.getColumnModel().getColumn(8).setCellRenderer(alinearderecha);
                  jtb_credito.getColumnModel().getColumn(9).setCellRenderer(alinearderecha);

                  jt_apartadoscatalogo.getColumnModel().getColumn(7).setCellRenderer(alinearderecha);
                  jt_apartadoscatalogo.getColumnModel().getColumn(8).setCellRenderer(alinearderecha);
                  jt_apartadoscatalogo.getColumnModel().getColumn(9).setCellRenderer(alinearderecha);

            }
    }


private void jt_apartadoscatalogoMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }

private void jtb_creditoMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }
private int fechasDiferenciaEnDias(Date fechaInicial, Date fechaFinal) {

      Calendar grefechamesini = Calendar.getInstance(); // obtiene la fecha actual
       grefechamesini.set(fechaInicial.getYear()+1900,fechaInicial.getMonth(),fechaInicial.getDate());
      Calendar grefechamesfin = Calendar.getInstance(); // obtiene la fecha actual
      grefechamesfin.set(fechaFinal.getYear()+1900,fechaFinal.getMonth(),fechaFinal.getDate());

     int dias=grefechamesfin.get(Calendar.DAY_OF_YEAR)-grefechamesini.get(Calendar.DAY_OF_YEAR);
     /*
        DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
        String fechaInicioString = df.format(fechaInicial);
            try {
                fechaInicial = df.parse(fechaInicioString);
                }
                catch (ParseException ex) {
                }

        String fechaFinalString = df.format(fechaFinal);
                try {
                    fechaFinal = df.parse(fechaFinalString);
                    }
                catch (ParseException ex) {
                    }

            long fechaInicialMs = fechaInicial.getTime();
            long fechaFinalMs = fechaFinal.getTime();
            long diferencia = fechaFinalMs - fechaInicialMs;
            double dias = Math.floor(diferencia / (1000 * 60 * 60 * 24));
      */
            return dias;
    }

 private String mensajetiempo(int nd) {
     String mensaje="";
     if (nd==0)
				{
					mensaje=" Hoy ";
				}
		if (nd==1)
				{
					mensaje=" ayer ";
				}
		if (nd>1)
				{
					mensaje=" Hace " + nd + " Dias " ;
				}
     if (nd<0)
				{
					mensaje=" Vence En " + nd + " Dias " ;
				}
 	return mensaje;
 }

  private Date fechadecadenaadate(String fe) {
      //recibe un la fecha en strin formato yyyy-MM-dd
       String dia = "";
       java.util.Date fecha=null;
       try{
             fecha = formateadoresta.parse(fe);
          }
        catch (ParseException e){
           //Error, la cadena de texto no se puede convertir en fecha.
          }

        return fecha;
 }
  void cambiartamanofilas()
{
     //limpiar la tabla
       int numerofilas=this.jtable_modelo.getRowCount();
           for(int i = 0 ;i < numerofilas; i++)
                {
                   jt_apartadoscatalogo.setRowHeight(i, 30);
                }
}

  void LimpiarJTable()
 {
     //limpiar la tabla
    while(jtable_modelo.getRowCount()>0)jtable_modelo.removeRow(0);
 }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ventas_sie_apartados_catalogo().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton jbtn_busqueda;
    private javax.swing.JButton jbtn_estadistica;
    private javax.swing.JComboBox jcbx_tiendas;
    private javax.swing.JLabel jlbl_cantidadregistros;
    private javax.swing.JLabel jlbl_textobuscado;
    private javax.swing.JMenuItem jmni_actualizar;
    private javax.swing.JMenuItem jmni_escape;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JRadioButton jrbtn_doctoanterio;
    private javax.swing.JRadioButton jrbtn_folio;
    private javax.swing.JRadioButton jrbtn_general;
    private javax.swing.JRadioButton jrbtn_obserdocto;
    private javax.swing.JTable jt_apartadoscatalogo;
    private javax.swing.JTable jtb_credito;
    private javax.swing.JTextField jtf_busqueda;
    // End of variables declaration//GEN-END:variables

}
